//
//  健康档案第一页
//  YZEPatientViewController.m
//  yilutongxing
//
//  Created by 赵继申 on 17/3/11.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import <EventKit/EventKit.h>
#import "YZEPatientViewController.h"
#import "YZEPatientCollectionViewCell.h"
#import "YZEPatientCollectionHeadView.h"
#import "YZEPatientHeadView.h"
#import "RPUserInfoBean.h"
#import "RPMedicineSinglePlan.h"
#import <MJExtension.h>
#import <QMUINavigationController.h>
#import "TimeTools.h"
#import "ZhuanXiangZhiBiaoViewController.h"
#import "DataUtils.h"
#import "CommonDefine.h"
#import "AppDelegate.h"
#import "TimeTools.h"

#import "HealthReportViewController.h" //健康报表
#import "TherapeuticRegimenViewController.h"//用药方案
#import "CheckNotesTableViewController.h" //检查报告
#import "OperationMessageTableViewController.h"//手术信息
#import "graftingHospitolViewController.h"//移植医院
#import "DailyTageViewController.h"////日常指标
#import "SpecialEventsViewController.h" //特殊事件

#define URL_GetOperationinfo @"/api/opertion/mine" //手术信息
#define URL_GetmydailyIndicator @"/api/dailyIndicator/mine" //最新日常指标
//#define URL_GetspecialIndicator @"/api/indicators/mine" //最新检查项目
#define URL_GetspecialIndicator @"/api/reports/mine?page=0&size=1"//&sort=checkTime,desc"
#define URL_Getmymedicineplan @"/api/sick-medicine-plans/today" //查询我的当天用药方案，闹钟提醒


@interface YZEPatientViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,
                                        NetworkUtilsDelegate>
{
    UICollectionReusableView *reusableView;
    YZEPatientHeadView *headView1;
    YZEPatientHeadView *headView2;
    YZEPatientHeadView *headView3;
    YZEPatientHeadView *headView4;
}
@property(nonatomic,strong) YZEPatientCollectionHeadView *collectionHeadView;
@property(nonatomic,strong) RPUserInfoBean *userInfo;
@property(nonatomic,strong)NSArray *imagesAddTitles;
@property(nonatomic,strong)NSMutableDictionary *headArrDataDic;

@property(nonatomic,strong) NSArray *checknotePropertyArr;//检查报告第一层检查项目属性名称数组

@property(nonatomic,strong) NSArray *zhNumberArr;//汉字数字字典
@end

@implementation YZEPatientViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //self.view.backgroundColor = COLOR(239, 239, 244);
    self.m_labelTitle.text = @"健康档案";
    [self initCollectionHeadView];
    [self initCollectionView];
    //应UI设计要求，在底部加上背景色补全……
    UIView *bottomgap = [[UIView alloc]initWithFrame:CGRectMake(0,
                                                                self.m_collectionView.y + self.m_collectionView.height,
                                                                SCREEN_WIDTH,
                                                                self.view.height - self.m_collectionView.height)];
    bottomgap.backgroundColor = COLOR(239, 239, 244);
    [self.view addSubview:bottomgap];
    
    self.imagesAddTitles=@[@"检查结果查阅",@"检查结果录入",@"用药方案",@"日常指标",@"诊疗过程",@"特殊事件"];
    
    [self renderHeadView];
}

- (void)viewWillAppear:(BOOL)animated{
    [self refreshAllData];
}

//头部数据
- (void)renderHeadView{
    //个人信息
    NSMutableArray *profileRowArr = [NSMutableArray array];
    NSDictionary *dic=[UserDefaultsTools getUserDefaultsForKey:USERINFO_KEY];
    self.userInfo=[RPUserInfoBean mj_objectWithKeyValues:dic];
    if (_userInfo.user.firstName) {
        YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
        model.cell_type = 2;
        model.col1 = @"姓名";
        model.col3 = _userInfo.user.firstName;
        [profileRowArr addObject:model];
    }
    if (_userInfo.gender) {
        YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
        model.cell_type = 2;
        model.col1 = @"性别";
        model.col3 = [_userInfo.gender isEqualToString:@"MALE"]?@"男":@"女";
        [profileRowArr addObject:model];
    }
    if (_userInfo.birthday) {
        YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
        model.cell_type = 2;
        model.col1 = @"年龄";
        NSArray *birthSplit = [_userInfo.birthday componentsSeparatedByString:@"-"];
        NSInteger birthYear = [birthSplit[0] integerValue];
        NSDate * senddate=[NSDate date];
        NSCalendar * cal=[NSCalendar currentCalendar];
        NSUInteger unitFlags= NSCalendarUnitDay|NSCalendarUnitMonth|NSCalendarUnitYear;
        NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate];
        NSInteger year=[conponent year];
        NSInteger age = (year-birthYear)>0?(year-birthYear):0;
        model.col3 = [NSString stringWithFormat:@"%ld", (long)age];
        [profileRowArr addObject:model];
    }
    if ((_userInfo.grafting)[@"name"]) {
        YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
        model.cell_type = 2;
        model.col1 = @"移植类型";
        model.col3 = (_userInfo.grafting)[@"name"];
        [profileRowArr addObject:model];
    }
    headView1.dataArr = profileRowArr;
    [headView1.tableView reloadData];
    //请求手术信息（为了拿手术日期）
    [self getOperationMessage];
    //用药方案数据
    [self getMedicinePlanData];
    //请求日常指标数据
    [self getDailyData];
    
    [self reqSpecialIndicator];
}

- (void)initCollectionView
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    flowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 300);
    _m_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 240 + 280) collectionViewLayout:flowLayout];
    _m_collectionView.backgroundColor = [UIColor colorWithRed:248/255.0 green:248/255.0 blue:248/255.0 alpha:1.0];
    _m_collectionView.delegate = self;
    _m_collectionView.dataSource = self;
    [_m_collectionView registerNib:[UINib nibWithNibName:@"YZEPatientCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"collectionCell"];
    [_m_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"ReusableView"];
    self.m_collectionView.backgroundColor = WHITE_COLOR;
    
    [self.view addSubview:_m_collectionView];

    __weak YZEPatientViewController *weakself = self;
    _m_collectionView.mj_header = [RefershHelper headerWithRefreshingBlock:^{
        [weakself refreshAllData];
        [_m_collectionView.mj_header endRefreshing];
    }];
}

-(void)initCollectionHeadView{
    headView1 = [[YZEPatientHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    headView1.row_height =@36;
    headView1.label_title.text=@"个人信息";
    headView2 = [[YZEPatientHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    [headView2 setIsMedicinePlan:YES];
    headView2.label_title.text=@"用药方案";
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(action1)];
    [headView2 addGestureRecognizer:tap1];
    headView3 = [[YZEPatientHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    headView3.label_title.text=@"日常指标";
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(action2)];
    [headView3 addGestureRecognizer:tap2];
    headView4 = [[YZEPatientHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    headView4.label_title.text=@"最新检查项目";
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(action3)];
    [headView4 addGestureRecognizer:tap3];
    _collectionHeadView = [[YZEPatientCollectionHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    _collectionHeadView.array_Views = [NSMutableArray arrayWithArray:@[headView1,headView2,headView3,headView4]];
}
-(void)action1{
    UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:[TherapeuticRegimenViewController new]];
    [self presentViewController:navi animated:YES completion:nil];
}
-(void)action2{
    UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:[DailyTageViewController new]];
    [self presentViewController:navi animated:YES completion:nil];
}
-(void)action3{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"HealthReport" bundle:[NSBundle mainBundle]];
    HealthReportViewController *v = [sb instantiateViewControllerWithIdentifier:@"healthreportVC"];
    UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:v];
    [self presentViewController:navi animated:YES completion:nil];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.imagesAddTitles.count;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    //debugLog(@"%ld",(long)indexPath.row);
    YZEPatientCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionCell" forIndexPath:indexPath];
    NSString *str= self.imagesAddTitles[indexPath.item];
    cell.imageView.image=[UIImage imageNamed:str];
    cell.label_title.text=str;
    //debugLog(@"screen_width:%d,h:%f,w:%f", SCREEN_WIDTH, cell.frame.size.height, cell.frame.size.width);
    [self.view bringSubviewToFront:cell];

    return cell;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    
    if (!reusableView) {
        reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:
                        UICollectionElementKindSectionHeader withReuseIdentifier:@"ReusableView" forIndexPath:indexPath];
        [reusableView addSubview:_collectionHeadView];
        reusableView.frame=CGRectMake(0, 0, SCREEN_WIDTH, 240);
    }
    
    return reusableView;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGSize size = CGSizeMake((SCREEN_WIDTH/3-0.2),(SCREEN_WIDTH/3-0.2));
    return size;
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(-70, 0, 0, 0);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 0.001;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 0.0;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:{
            UIStoryboard *sb = [UIStoryboard storyboardWithName:@"HealthReport" bundle:[NSBundle mainBundle]];
            HealthReportViewController *healthreport = [sb instantiateViewControllerWithIdentifier:@"healthreportVC"];
            UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:healthreport];
            [self presentViewController:navi animated:YES completion:nil];
        }

            break;
        case 1:{
            CheckNotesTableViewController *check=[CheckNotesTableViewController new];
            UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:check];
            [self presentViewController:navi animated:YES completion:nil];
        }
            break;
        case 2:{
            TherapeuticRegimenViewController *thera=[TherapeuticRegimenViewController new];
            QMUINavigationController *navi=[[QMUINavigationController alloc]initWithRootViewController:thera];
            [self presentViewController:navi animated:YES completion:nil];
        }
            break;
       case 3:{
           DailyTageViewController *dailytage = [DailyTageViewController new];
           UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:dailytage];
           [self presentViewController:navi animated:YES completion:nil];
        }
            break;
        case 4:{
            OperationMessageTableViewController *vc=[OperationMessageTableViewController new];
            UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:vc];
            [self presentViewController:navi animated:YES completion:nil];
        }
            break;
        case 5:{
            SpecialEventsViewController *vc = [SpecialEventsViewController new];
            UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:vc];
            [self presentViewController:navi animated:YES completion:nil];
        }
            break;
      
    }
    
}

#pragma mark - 数据请求
- (void)updateSpecialIndicator:(NSDictionary*)checknotePropertyChineseDic{
    //检查项目
    [[YZENetwork sharedInstace]getRequestWithUrl:[BASE stringByAppendingString:URL_GetspecialIndicator]
                                      parameters:nil
                                        delegate:self
                                      requestTag:4 successBlock:^(id responseObject)
     {
         NSArray *retdata = (NSArray*)responseObject;
         if (retdata.count==0) {
             return;
         }
         dispatch_async(GLOBAL_BG_QUEUE, ^{
             NSDictionary *backData =retdata[0];
             NSMutableArray *rowArr = [NSMutableArray array];
             for (int i=0; i<self.checknotePropertyArr.count; i++) {
                 NSString *key = self.checknotePropertyArr[i];
                 NSDictionary *fm = [backData valueForKey:key];//条目数值
                 NSArray *subkeys = [fm allKeys];
                 NSDictionary *item;
                 NSString *cn;
                 NSString *subkey;
                 NSString *value;
                 for (int j=0; j<subkeys.count; j++) {
                     subkey = subkeys[j];
                     item = [checknotePropertyChineseDic valueForKey:subkey];
                     cn = [item valueForKey:@"translateProperty"];
                     value = [fm valueForKey:subkey];
                     if (item && cn && ![value isEqualToString:@""]) {
                         YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
                         model.cell_type = 2;
                         model.col1 = cn;
                         model.col3 = [NSString stringWithFormat:@"%@%@", value, item[@"unit"]];
                         [rowArr addObject:model];
                     }
                 }
             }
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 headView4.dataArr = rowArr;
                 [headView4.tableView reloadData];
             });
         });
     }];
}

- (void)refreshAllData{
    //请求手术信息（为了拿手术日期）
    [self getOperationMessage];
    //用药方案数据
    [self getMedicinePlanData];
    //请求日常指标数据
    [self getDailyData];
}
//请求手术信息（为了拿手术日期）
- (void)getOperationMessage{
    [[YZENetwork sharedInstace]getRequestWithUrl:[BASE stringByAppendingString:URL_GetOperationinfo]
                                      parameters:nil
                                        delegate:self
                                      requestTag:3 successBlock:^(id responseObject)
     {
         if (responseObject[@"opTime"]) {
             NSString *opTime = responseObject[@"opTime"];
             YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
             model.cell_type = 2;
             model.col1 = @"手术时间";
             model.col3 = [NSString stringWithFormat:@"术后%@", [TimeTools getTimeGapHumanDescForDate:opTime]];
             if (headView1.dataArr.count>4) {
                 [headView1.dataArr removeObjectAtIndex:4];
             }
             [headView1.dataArr addObject:model];
             [headView1.tableView reloadData];
         }
     }];
}
//拉取用药方案数据
- (void)getMedicinePlanData{
    [[YZENetwork sharedInstace]getRequestWithUrl:[BASE stringByAppendingString:URL_Getmymedicineplan]
                                      parameters:nil
                                        delegate:self
                                      requestTag:1
                                    successBlock:^(id responseObject)
     {
         NSMutableArray *rowArr = [NSMutableArray array];
         NSArray *plans = [RPMedicineSinglePlan mj_objectArrayWithKeyValuesArray:responseObject];
         NSMutableArray *alert_arr = [NSMutableArray array];
         NSDictionary *setting = [UserDefaultsTools getUserDefaultsForKey:SETTING];
         NSNumber *medicine_alert_flag = !setting?[NSNumber numberWithBool:YES]:(!setting[MEDICINE_ALERT_TOOGLE]?[NSNumber numberWithBool:YES]:setting[MEDICINE_ALERT_TOOGLE]);
         BOOL isAlert = [medicine_alert_flag boolValue];
         for (int i=0; i<plans.count; i++) {
             RPMedicineSinglePlan *plan = plans[i];
             [self addTakeMedicineClockAlert:plan.times toArr:alert_arr];
             YZEPatientHeadViewCellModel *model1 = [YZEPatientHeadViewCellModel new];
             model1.cell_type = 4;
             model1.col1 = plan.medicine.name?plan.medicine.name:plan.medicineName;
             model1.col2 = plan.frequency;
             
             NSArray *dose_arr;
             dose_arr = [DataUtils getTidyArrayFromString:plan.dose];
             NSArray *unit_arr;
             unit_arr = [DataUtils getTidyArrayFromString:plan.unit];
             NSString *eatime = [NSString string];
             if (unit_arr.count==dose_arr.count) {
                 for (int m=0; m<dose_arr.count; m++) {
                     eatime = [eatime stringByAppendingString:[NSString stringWithFormat:@"第%@次 %@%@   ", self.zhNumberArr[m], dose_arr[m], unit_arr[m]]];
                 }
             }
             else {
                 for (int n=0; n<dose_arr.count; n++) {
                     eatime = [eatime stringByAppendingString:[NSString stringWithFormat:@"第%@次 %@%@   ", self.zhNumberArr[n], dose_arr[n], unit_arr[0]]];
                 }
             }
             
             model1.col3 = eatime;
             [rowArr addObject:model1];
         }
         if (isAlert) {
             AppDelegate *app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             [TimeTools addClockAlert:alert_arr forTitle:@"请按时服药" intoDB:[app sharedEventStore]];
         }
         headView2.dataArr = rowArr;
         [headView2.tableView reloadData];
     }];
}
//拉取日常指标数据
- (void)getDailyData{
    NSArray *dailyIndicatorNameArr = @[@"血压", @"血糖", @"餐后血糖2h", @"尿量", @"体温", @"体重", @"身高"];
    [[YZENetwork sharedInstace]getRequestWithUrl:[BASE stringByAppendingString:URL_GetmydailyIndicator]
                                      parameters:nil
                                        delegate:self
                                      requestTag:2
                                    successBlock:^(id responseObject)
     {
         dispatch_async(GLOBAL_BG_QUEUE, ^{
             NSString *date = [TimeTools getYearMonthDayWithTimeString:responseObject[@"date"]];
             NSMutableArray *rowArr = [NSMutableArray array];
             for (NSString *name in dailyIndicatorNameArr) {
                 YZEPatientHeadViewCellModel *model = [YZEPatientHeadViewCellModel new];
                 model.col1 = name;
                 model.col3 = @"未录入";
                 [rowArr addObject:model];
             }
             YZEPatientHeadViewCellModel *model0 = rowArr[0];
             model0.cell_type = 3;
             if (responseObject[@"lowPressure"] && responseObject[@"highPressure"]
                 && ![responseObject[@"lowPressure"] isEqualToString:@""] && ![responseObject[@"highPressure"] isEqualToString:@""]) {
                 model0.col2 = [NSString stringWithFormat:@"%@/%@ mmhg", responseObject[@"highPressure"], responseObject[@"lowPressure"]];
                 model0.col3 = date;
             }
             YZEPatientHeadViewCellModel *model1 = rowArr[1];
             model1.cell_type = 3;
             if (responseObject[@"bloodSugar"] && ![responseObject[@"bloodSugar"] isEqualToString:@""]) {
                 model1.col2 = [NSString stringWithFormat:@"%@ mmol/l", responseObject[@"bloodSugar"]];
                 model1.col3 = date;
             }
             YZEPatientHeadViewCellModel *model2 = rowArr[2];
             model2.cell_type = 3;
             if (responseObject[@"bloodSugar2"] && ![responseObject[@"bloodSugar2"] isEqualToString:@""]) {
                 model2.col2 = [NSString stringWithFormat:@"%@ mmol/l", responseObject[@"bloodSugar2"]];
                 model2.col3 = date;
             }
             YZEPatientHeadViewCellModel *model3 = rowArr[3];
             model3.cell_type = 3;
             if (responseObject[@"urine"] && ![responseObject[@"urine"] isEqualToString:@""]) {
                 model3.col2 = [NSString stringWithFormat:@"%@ ml", responseObject[@"urine"]];
                 model3.col3 = date;
             }
             YZEPatientHeadViewCellModel *model4 = rowArr[4];
             model4.cell_type = 3;
             if (responseObject[@"temperature"] && ![responseObject[@"temperature"] isEqualToString:@""]) {
                 model4.col2 = [NSString stringWithFormat:@"%@ ℃", responseObject[@"temperature"]];
                 model4.col3 = date;
             }
             YZEPatientHeadViewCellModel *model5 = rowArr[5];
             model5.cell_type = 3;
             if (responseObject[@"weight"] && ![responseObject[@"weight"] isEqualToString:@""]) {
                 model5.col2 = [NSString stringWithFormat:@"%@ kg", responseObject[@"weight"]];
                 model5.col3 = date;
             }
             YZEPatientHeadViewCellModel *model6 = rowArr[6];
             model6.cell_type = 3;
             if (responseObject[@"height"] && ![responseObject[@"height"] isEqualToString:@""]) {
                 model6.col2 = [NSString stringWithFormat:@"%@ cm", responseObject[@"height"]];
                 model6.col3 = date;
             }
             YZEPatientHeadViewCellModel *model7 = [YZEPatientHeadViewCellModel new];
             model7.cell_type = 3;
             model7.col1 = @"BMI";
             if (model5.col2 && model6.col2) {
                 double weight = [model5.col2 doubleValue];
                 double height = [model6.col2 doubleValue];
                 double bmi = (weight*10000)/(height*height);
                 model7.col2 = [NSString stringWithFormat:@"%.1f", bmi];
             }
             else
                 model7.col3 = @"未收录";
             
             [rowArr addObject:model7];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 headView3.dataArr = rowArr;
                 [headView3.tableView reloadData];
             });
         });
     }];
}

#pragma mark - 数据配置
- (NSArray*)checknotePropertyArr {
    if (!_checknotePropertyArr) {
        _checknotePropertyArr = @[
                                         @"blood", @"bloodfat", @"coagulation", @"hepatitis",
                                         @"immunologic", @"liver", @"outineblood", @"renal", @"tumormarker",
                                         @"urinalysis", @"viralinfection"
                                 ];
    }
    return _checknotePropertyArr;
}

- (void)reqSpecialIndicator {
        BOOL ret = [DataUtils fileIfExists:PROINDEXARR];//本地是否有缓存
        if (!ret) {
            //网络请求指标字典
            [ZhuanXiangZhiBiaoViewController requestIndicatorData:^(NSArray *i, NSDictionary *subi) {
                NSString *subProIndexdicPath = [NSString stringWithFormat:@"%@/%@", [DataUtils getDocumentsPath], SUBPROINDEXDIC];
                NSDictionary *t_checknotePropertyChineseDic = [NSDictionary dictionaryWithContentsOfFile:subProIndexdicPath];
                [self updateSpecialIndicator:t_checknotePropertyChineseDic];
            }];
        }
        else {
            ret = [DataUtils fileIfExists:SUBPROINDEXDIC];
            if (!ret) {
                NSLog(@"[ERROR]没找到专项指标处理后的字典!");
            }
            else {
                NSString *subProIndexdicPath = [NSString stringWithFormat:@"%@/%@", [DataUtils getDocumentsPath], SUBPROINDEXDIC];
                NSDictionary *t_checknotePropertyChineseDic = [NSDictionary dictionaryWithContentsOfFile:subProIndexdicPath];
                [self updateSpecialIndicator:t_checknotePropertyChineseDic];
            }
        }
}

- (NSArray*)zhNumberArr{
    if (!_zhNumberArr) {
        _zhNumberArr = @[@"一", @"二", @"三", @"四"];
    }
    return _zhNumberArr;
}

#pragma mark - 根据时间字符串添加闹钟
- (void)addTakeMedicineClockAlert:(NSString*)timeStr toArr:(NSMutableArray*)date_arr{
    NSMutableArray *timeArr = [[timeStr componentsSeparatedByString:@","] mutableCopy];
    NSEnumerator *en = [timeArr reverseObjectEnumerator];
    NSString *time = nil;
    
    while (time = [en nextObject]) {
        if ([time isNotEmpty]) {
            NSString *today = [TimeTools getYearMonthDayWithDate:[NSDate date]];
            NSString *str = [NSString stringWithFormat:@"%@ %@", today, time];
            NSDate *clock = [TimeTools getDateWithString:str];
            
            [date_arr addObject:clock];
        }
    }
}
#pragma mark - 网络请求返回
- (void)OnFail:(NSString *)errorMsg errorCode:(NSInteger)errorCode requestTag:(int)tag{
    if (errorCode==NSURLErrorBadServerResponse) {
        debugLog([NSString stringWithFormat:@"无数据 tag=%d", tag]);
    }
}

@end
